package date

import (
	"fmt"
	"strings"
)

const (
	// SecondsPerMinute 定义每分钟的秒数
	SecondsPerMinute = 60

	// SecondsPerHour 定义每小时的秒数
	SecondsPerHour = SecondsPerMinute * 60

	// SecondsPerDay 定义每天的秒数
	SecondsPerDay = SecondsPerHour * 24
)

func SecondsSwitchTime(seconds int) string {
	if seconds <= 0 {
		return "0秒"
	}

	var builder strings.Builder
	day := seconds / SecondsPerDay
	if day >= 1 {
		seconds %= SecondsPerDay
		builder.WriteString(fmt.Sprintf("%d天", day))
	}

	hour := seconds / SecondsPerHour
	if hour >= 1 {
		seconds %= SecondsPerHour
		builder.WriteString(fmt.Sprintf("%d时", hour))
	}

	minute := seconds / SecondsPerMinute
	if minute >= 1 {
		seconds %= SecondsPerMinute
		builder.WriteString(fmt.Sprintf("%d分", minute))
	}

	if seconds >= 1 {
		builder.WriteString(fmt.Sprintf("%d秒", seconds))
	}

	return builder.String()
}
